<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="订单号:" prop="sn">
        <el-input
          size="mini"
          v-model="queryParams.sn"
          placeholder="请输入订单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户信息:" prop="member">
        <el-input
          size="mini"
          v-model="queryParams.member"
          placeholder="请输入邮箱/编号/姓名/昵称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易类型:" prop="scene">
        <el-select v-model="queryParams.scene" clearable placeholder="请选择交易类型" size="mini">
          <el-option
            v-for="dict in dict.type.quote_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="交易状态:" prop="status">
        <el-select v-model="queryParams.status" clearable placeholder="请选择交易状态" size="mini">
          <el-option
            v-for="dict in dict.type.crypto_transfers_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="卖出币种:" prop="sourceCurrency">
        <el-input
          size="mini"
          v-model="queryParams.sourceCurrency"
          placeholder="请输入卖出币种"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="买入币种:" prop="destinationCurrency">
        <el-input
          size="mini"
          v-model="queryParams.destinationCurrency"
          placeholder="请输入买入币种"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="询价币种:" prop="rfqCurrency">
        <el-input
          size="mini"
          v-model="queryParams.rfqCurrency"
          placeholder="请输入询价币种"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易时间:">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          format="yyyy-MM-dd"
          value-format="timestamp"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="['00:00:00', '23:59:59']"
          size="mini"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="序号" type="index" align="center" min-width="5%"/>
      <el-table-column label="用户信息" align="center" prop="uid" key="uid">
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="goMemberDetail(scope.row)"
          >
            用户信息
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="sn" key="sn"/>
      <el-table-column label="交易类型" align="center" prop="scene" key="scene">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.quote_type" :value="scope.row.scene"/>
        </template>
      </el-table-column>
      <el-table-column label="卖出币种" align="center" prop="sourceCurrency" key="sourceCurrency"/>
      <el-table-column label="买入币种" align="center" prop="destinationCurrency" key="destinationCurrency"/>
      <el-table-column label="询价币种" align="center" prop="rfqCurrency" key="rfqCurrency"/>
      <el-table-column label="询价数量" align="center" prop="rfqAmount" key="rfqAmount"/>
      <el-table-column label="交易时间" align="center" prop="createTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="交易状态" align="center" prop="status" key="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.crypto_transfers_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="goTransfersDetail(scope.row)"
            v-hasPermi="['system:quoteTransfers:query']"
          >详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <member-detail ref="member-detail"/>
    <quote-transfers-detail ref="quote-transfers-detail"/>
  </div>
</template>
<script>
import memberDetail from "@/views/triones/member/memberUser/memberDetail";
import quoteTransfersDetail from "@/views/triones/crypto/mixExchange/quoteTransfersDetail";
import { quoteTransfersPageList } from '@/api/triones/interlaceCryptoTransfers'
export default {
  name: "index",
  components: {memberDetail,quoteTransfersDetail},
  dicts: ['crypto_transfers_status','quote_type'],
  data() {
    return {
      loading: false,
      showSearch: true,
      dateRange: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sn: undefined,
        member: undefined,
        scene: undefined,
        status: undefined,
        sourceCurrency: undefined,
        destinationCurrency: undefined,
        rfqCurrency: undefined
      },
      dataList: [],
      total: 0
    }
  },
  created() {
    this.getList();
  },
  methods: {
    goMemberDetail(row) {
      this.$refs["member-detail"].show(row.uid);
    },
    /** 交易列表 */
    getList() {
      this.loading = true;
      this.addDateRange(this.queryParams, this.dateRange);
      quoteTransfersPageList(this.queryParams).then(res => {
        this.dataList = res.rows;
        this.total = res.total;
        this.loading = false;
      })
    },
    /** 检索 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    goTransfersDetail(row) {
      this.$refs["quote-transfers-detail"].show(row.id);
    }
  }
}
</script>
<style scoped lang="scss">

</style>
